package com.mrjy.maintain.dao;

import com.mrjy.common.dto.MemberListDto;
import com.mrjy.common.dto.UserHappinessDto;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.entity.VideoInfo;

import java.util.List;
import java.util.Map;


public interface IUserInfoDao {
	//插入用户
	int insert(UserInfo userInfo);
	
	/**选择性插入用户
	 *  
	 * @param userInfo  其中login_code, password, user_name,register_date,role_id必须不为空
	 * @return
	 */
	int insertSelective(UserInfo userInfo);
	
	//根据账号查询用户
	UserInfo queryByLoginCode(String loginCode);

	/**
	 * 多方式登录    账号、手机号码、邮箱
	 * @param loginCode
	 * @return
	 */
	UserInfo login(String loginCode);
	
	/**
	 * Email验证
	 * @param email
	 * @return
	 */
	public UserInfo queryByEmail(String email);
	/**
	 * 手机号码验证
	 * @param mobilePhone
	 * @return
	 */
	public UserInfo queryByMobilePhone(String mobilePhone);
	public List<UserInfo> queryByMobilePhoneIgnoreDisable(String mobilePhone);
	
	//根据推荐码查询老师
	public UserInfo queryByRecommendCode(String recommendCode);
	
	//获取老师或服务站名下开通的会员
	public List<UserInfo> queryMemberList(UserInfo userInfo);
	
	//获取老师或服务站名下开通的会员的总数
	public int queryMemberListTotal(UserInfo userInfo);
	/**
	 * 导出老师名下开通的会员列表Excel表格
	 * @param userInfo
	 * @return
	 */
	public List<MemberListDto> exportMemberList(UserInfo userInfo);
	
	/**
	 * 密保验证
	 * @param userInfo   loginCode,email,mobilePhone
	 * @return
	 */
	UserInfo queryBySafeValidate(UserInfo userInfo);
	
	//分页查询用户
	List<UserInfo> queryPageUser(UserInfo userInfo);
	
	//根据角色统计用户
	int countUser(UserInfo userInfo);
	
	//统计用户总数
    int countUserInfo(UserInfo userInfo);

    /**
	 * 后台根据查询老师列表
	 * @return
	 */
	List<UserInfo> queryTeacherList(UserInfo userInfo);
	/**
	 * 后台根据查询服务站信息列表
	 * @return
	 */
	List<UserInfo> queryStationList();
	
	//根据账号查询用户
	UserInfo queryById(int id);
	
	/**
	 * 查询老师和服务站的分成 费用
	 * @param id
	 * @return
	 */
	float queryTeacherCommission(int id);
	
	//根据ID修改用户
	int updateById(UserInfo userInfo);
	
	//根据ID删除用户
	int deleteByIds(int[] ids);
	
	//根据ID禁用、起用用户
	int updateDisableFlag(UserInfo userInfo);
	
	//教师标签列表
	List<UserInfo> queryLableTypeList();

	//根据微信提供的独立openid进行用户查询
	UserInfo queryByWeixinOpenid(String opid);
	
	//修改用户登录状态
	int updateSession2(UserInfo userInfo);

    //修改用户登录状态 for pc
    int updateSessionPC(UserInfo userInfo);
	
	String querySessionByUserId(int id);

    String queryPCSessionByUserId(int id);
	
	int countListByRoleId(UserInfo userInfo);
	
	List<UserInfo> queryListByRoleId(UserInfo userInfo);
	/**
	 * 通用，通过对象传参查询对象
	 * @param tempUser
	 * @return
	 * @author csshui
	 */
	UserInfo selectByUserInfo(UserInfo tempUser);
	/**
	 * 新用户微信授权验证手机后绑定信息
	 * @param info
	 * @return
	 */
	int txInsertWechatInfo(UserInfo info);

	UserInfo queryBindingUserInfoById(int id);
	/**
	 * 通过手机号码查询是不已被注册
	 * @author csshui
	 * @param mobilePhone
	 * @return 
	 */
	public int mobilePhoneValid(String mobilePhone);
	/**
	 * 通过分享码验证，该验证码是否有效
	 * @param shareCode
	 * @return
	 */
	public int selectByShareCode(String shareCode);

	UserInfo queryByOpenId(UserInfo info);

	int countPageTeacherByVideoDesc(UserInfo info);

    int countPageTeacherByVideoDesc(VideoInfo info);

    int countPageTeacherBySortType(UserInfo info);

	List<UserInfo> queryPageTeacherByVideoDesc(UserInfo info);

    UserInfo queryPageTeacherByUserName(VideoInfo info);
    /**
     *
     * @param videoInfo
     * @return
     */
    List<UserInfo> queryPageTeacherByTypename(VideoInfo videoInfo);

    List<UserInfo> queryPageTeacherByPlaytimes(VideoInfo info);

    List<UserInfo> queryPageTeacherByNewest(VideoInfo info);

    int countTeacherByTypename(VideoInfo videoInfo);
	/**
	 * 通过手机绑定微信
	 * @param info
	 * @return
	 */
	public int txToBindingByMobilePhone(UserInfo info);
	/**
	 * 通过微信openId绑定手机
	 * @param info
	 * @return
	 */
	public int txToBindingByOpenId(UserInfo info);
	/**
	 * 通过微信openId 查询是否为vip
	 * @param openId
	 * @return
	 */
	public UserInfo isVipByOpenId(String openId);
	/**
	 * 通过id查询老师
	 * @param id
	 * @return
	 */
	public UserInfo getTeacherInfoById(int id);

	int countTeacherByName(UserInfo info);

	List<UserInfo> getPageTeacherByName(UserInfo info);

	public UserInfo isBindedByOpenId(String openId);

	List<UserInfo> queryPageTeacherByOrderNum(UserInfo info);

	UserInfo selectUserById(int id);

	List<UserInfo> selectByPartnerId(Integer id);

	int insertShareCodeByUserId(Map<String, Object> paramMap);

	String generateRecommendCode(Map<String, Object> paramMap);
	
	String generateRecommendCodeOne(Integer num);
	
	UserInfo queryByIdForBack(Integer id);

	UserInfo queryAdminByPartnerId(Integer partnerId);
	
	UserInfo isPartnerByRecommendCode(String recommendCode);
	
	UserInfo isStationByRecommendCode(String recommendCode);
	
	UserInfo isTeacherByScanShareCode(String recommendCode);
	
	List<UserInfo> selectByUserName(String userName);
	
	UserInfo queryAdminByStationId(Integer stationId);

    List<UserInfo> queryPageTeacherWithRecordAndCourse(UserInfo info);
    
    List<UserInfo> queryPageTeacherWithRecord(UserInfo info);

    List<UserInfo> loginAdmin(String loginCode);

	/**
	 * 根据station_id删除
	 * @param ids
	 */
	void deleteByStationIds(int[] ids);


	/**
	 * 分页查询
	 * @param userInfo
	 * @return
	 */
	List<UserInfo> queryPageUser2(UserInfo userInfo);


    UserInfo queryTeacherInfoWithRecord(UserInfo info);
    
    
	/**
	 * 根据服务站ID查询用户
	 * @param id
	 * @return
	 */
	UserInfo queryByStationIdForBack(Integer id);
	/**
	 * 通过id查询密码密文
	 * @param id
	 * @return
	 */
	UserInfo queryPasswordById(Integer id);
    UserInfo queryBankCardInfoById(UserInfo userInfo);
	UserInfo queryAdminBySchoolId(int schoolId);
 
	int updateAdminUserById(UserInfo userInfo);

	List<UserInfo> queryMyPraise();
	UserInfo queryMyPraiseById(Integer id);
    UserInfo queryByWeixinUnionid(String weixinOpenid);

	UserInfo queryByMobilePhoneExist(String mobilePhone);

	int updateStationIdAndRoleId(UserInfo ui);

	int updateOpenIdById(UserInfo info);

	List<UserHappinessDto> queryHappinessRank(UserHappinessDto dto);

    List<UserHappinessDto> queryStudyRecord(UserHappinessDto dto);

    UserHappinessDto queryTotalStudyRecord(UserHappinessDto dto);
    
    int queryIntegralBalanceByUserId(Integer userId);

	UserInfo queryByPartnerId(Integer id);


    List<UserInfo> queryWisdomUserDaily(UserInfo info);

    List<UserInfo> queryWisdomUserAll(UserInfo info);

    List<UserHappinessDto> queryHappinessRankWithoutTeacher(UserHappinessDto dto);

    List<UserInfo> queryStudyUserDaily();

	UserInfo queryByWUnionid(String unionid);

	UserInfo queryByUnionId(UserInfo info);

	UserInfo isVipByUnionId(String weixinOpenid);

    List<UserInfo> queryHappinessWall(UserInfo info);

    UserInfo querySimpleInfoById(Integer id);

	UserInfo queryByWxMiniOpenId(String openid);
	
	List<UserInfo> queryWeixinOpenidList();
}
